import re
from typing import List


max_n = 200+5

dp:List[List[int]] = [[0]*max_n for _ in range(max_n)]

while True:
    try:
        raw_str = input().strip()
        a, b = map(lambda x:" "+x, re.split(r"\s+",raw_str,maxsplit=1))
    except EOFError:
        break

    for i in range(1,len(a)):
        for j in range(1,len(b)):
            if a[i] == b[j]:
                # print(i,j,"ok")
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    
    # print(dp,repr(a),repr(b))
    print(dp[len(a)-1][len(b)-1])